
<template>
  <el-dialog v-model="ifShow" title="审核" width="60rem" :before-close="handleCancel">
    <el-form ref="formRef" :model="formData" :rules="rules" label-width="auto" class="demo-ruleForm" status-icon>
      <el-form-item label="是否通过" prop="op">
        <el-select v-model="formData.op" placeholder="请选择">
          <el-option :value="1" label="通过"></el-option>
          <el-option :value="2" label="拒绝"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="拒绝原因" prop="reason">
        <el-input v-model="formData.reason" placeholder="请输入"></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleCancel">取消</el-button>
        <el-button type="primary" @click="handleOk">确认</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import CommonApi from "@/api/common";
import JntApi from "@/api/jnt";
import Supplier from "@/api/supplier";
import { channelArr, bizTypeArr, orderTypeArr, platFormArr, carTypeArr } from "@/enums/common";
import DriverApi from "@/api/driver";

const props = defineProps<{}>();
const emit = defineEmits(["success"]);
const formRef: any = ref(null);
const formData: any = reactive({
  op: "",
  id: "",
  reason: "",
});
const rules = reactive({
  op: [{ required: true, message: "请选择!" }],
  userId: [{ required: true, message: "请输入用户id!" }],
  fund: [{ required: true, message: "请输入提现金额 单位：分!" }],
});
const ifShow = ref(false);
function edit(row: any) {
  ifShow.value = true;
  //赋值
  Object.assign(formData, row);
}

/**
 * 确定按钮点击事件
 */
async function handleOk() {
  await formRef.value.validate((valid: any, fields: any) => {
    if (valid) {
      let model = {
        id: formData.id,
        op: formData.op,
        reason: formData.reason,
      };
      DriverApi.driverConfirmAudit(model).then((res: any) => {
        if (res.code == 0) {
          ElMessage.success(res.message);
          formRef.value.resetFields();
          emit("success");
          handleCancel();
        }
      });
    } else {
      console.log("error submit!", fields);
    }
  });
}

/**
 * 取消按钮回调事件
 */
function handleCancel() {
  formRef.value.resetFields();
  ifShow.value = false;
}

defineExpose({
  edit,
});
onMounted(() => {});
</script>
<style lang="scss" scoped>
.flex_box {
  display: flex;
  margin-bottom: 14px;
  position: relative;
}
</style>
